package com.homelock.constants;

public enum LockCmdEnum {
    EMPTY("",-1,-1,"空"),
    ADD_USER("4_7",0x07,4,"添加用户"),
    DEL_USER("4_8",0x08,4,"删除用户"),
    OPEN_RECORD("0",-1,0,"开门记录"),
    ALARM_RECORD("2",-1,2,"报警记录");

    String value;  // processor分类code
    byte code;  // 分类code
    byte optCode; // 指令code
    String name;

    LockCmdEnum(String value,int code,int optCode,String name){
        this.name = name;
        this.value = value;
        this.code = (byte)code;
        this.optCode = (byte)optCode;
    }

    public static LockCmdEnum codeOf(byte code){
       for (LockCmdEnum item :values()){
           if(item.getCode() == code){
               return item;
           }
       }
       return EMPTY;
    }

    public static LockCmdEnum optCodeOf(byte optCode){
        for (LockCmdEnum item :values()){
            if(item.getOptCode() == optCode){
                return item;
            }
        }
        return EMPTY;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public byte getCode() {
        return code;
    }

    public byte getOptCode() {
        return optCode;
    }

    public void setOptCode(byte optCode) {
        this.optCode = optCode;
    }

    public void setCode(byte code) {
        this.code = code;
    }
}
